module game {
    export class Processor_QZNN extends puremvc.SimpleCommand implements puremvc.ICommand {
        public constructor() {
            super();
        }
        public static NAME: string = "Processor_QZNN";
        private qznnProxy: QznnProxy = null;
        /**
         * 注册消息
         */
        public register(): void {
            this.facade.registerCommand("Processor_QZNN", Processor_QZNN);
        }

        public execute(notification: puremvc.INotification): void {
            this.qznnProxy = QznnProxy.getProxy();
            var Data: any = notification.getBody();//携带数据
            let msgdata = DataParser.WSReceiveMsg(RegDataQznn, Data);
            if (Global.isEmpty(msgdata)) {
                return;
            }
            let mainCmd = msgdata["mainCmd"];
            let subCmd = msgdata["subCmd"];
            let data = msgdata["msgData"];
            if (InstructionsEnum.IS_TEST) {
                console.log("抢庄牛牛接收：", mainCmd, subCmd, msgdata)
            }
            if (Global.isEmpty(data)) {
                return;
            }
            switch (mainCmd) {
                case 1: {

                    if (subCmd == 100) {//登陆成功
                        this.qznnProxy.login(data);
                    }
                    if (subCmd == 101) {//登陆成功              
                        Global.tipShow(data["szDescribeString"]);
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.QZNN);
                        InstructionsEnum.ID_GAME = "";
                    }
                    if (subCmd == 102) {//登陆完成
                        let obj = {
                            wVisit: 0,
                            wVersion: 101122049,
                            wGameVersion: 101122049
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GF_GameOption, obj, true);
                        // SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserQuickSitdown, new Object(), false)
                    }
                    if (subCmd == 103) {
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.QZNN);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.HALL_RECONNECTGAME, data["wServerID"]);
                    }
                    if (subCmd == 104) {
                        this.qznnProxy.Relink();
                    }
                    break;
                }
                case 2: {
                    if (subCmd == 100) {

                    }
                    if (subCmd == 101) {//房间配置
                        this.qznnProxy.getRoomInfo(data);
                    };
                    if (subCmd == 103) {//房间配置完成

                    };
                    break;
                }
                case 3: {
                    if (subCmd == 100) {//用户进入房间
                        this.qznnProxy.joinRoom(data);
                    }
                    if (subCmd == 101) {//用户分数
                        this.qznnProxy.updataUsersScore(data);
                    }
                    if (subCmd == 102) {//返回单个用户状态
                        this.qznnProxy.getUserInfo(data);
                    }
                    if (subCmd == 103) {//钱不够入座
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.QZNN)
                        Global.tipShow(data["szDescribeString"])
                    }
                    break;
                }
                case 4: {
                    if (subCmd == 100) {//请求坐下
                        let obj = {
                            wTableID: 65535,
                            wChairID: 65535,
                            szInsurePass: ""
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.QZNN, RegDataQznn.CMD_GP_UserQuickSitdown, obj, true);
                    }
                    break;

                }
                case 100: {
                    if (subCmd == 100) {
                        //空闲
                        if (data["cbGameStatus"] == 0) {
                            RegDataQznn.MainCMD_MsgId[100][101] = RegDataQznn.free
                        }
                        //抢庄
                        if (data["cbGameStatus"] == 100) {
                            RegDataQznn.MainCMD_MsgId[100][101] = RegDataQznn.gameCall
                        }
                        // 下注
                        if (data["cbGameStatus"] == 101) {
                            RegDataQznn.MainCMD_MsgId[100][101] = RegDataQznn.gameScore
                        }
                        // 游戏开始
                        if (data["cbGameStatus"] == 102) {
                            RegDataQznn.MainCMD_MsgId[100][101] = RegDataQznn.gamePlay
                        }
                    }
                    if (subCmd == 101) {
                        this.qznnProxy.dataRecovery(data);
                    } else if (subCmd == 104) {

                    } else if (subCmd == 200) {//后端推送消息
                        if (data["wType"] == 515) {
                            Global.tipShow(data["szString"]);
                        } else {
                            EffectUtils.textFadeAway(data["szString"]);
                        }
                    }
                    if (subCmd == 300) {//牌局编号
                        this.qznnProxy.getSerialNumber(data);
                    }
                    break;
                }
                case 200: {
                    // egret.log(mainCmd, subCmd, data)

                    switch (subCmd) {
                        case 100: {  //开始
                            this.qznnProxy.StartGame(data);
                            break;
                        }
                        case 101: {  //玩家加注
                            this.qznnProxy.Xianjiaxiazhu(data);
                            break;
                        }
                        case 102: {  //用户强退
                            break;

                        }
                        case 103: { //系统发牌
                            this.qznnProxy.sysSendCard(data);
                            break;
                        }
                        case 104: {
                            //单局结算
                            QznnVO.getVo().myGameStatus = 0;
                            this.qznnProxy.ShowHandCard(data);
                            // this.qznnProxy.singleEnd(data);

                            break;
                        }
                        case 105: {  //用户摊牌
                            this.qznnProxy.playerShowCard(data);
                            break;
                        }
                        case 106: {  //游戏叫庄状态
                            if (data["wCallBanker"] == 65535) {
                                QznnVO.getVo().qiangzhuangtime = 9;
                                QznnVO.getVo().myGameStatus = 1;
                                game.AppFacade.getInstance().sendNotification(PanelNotify.QZNN.START_QIANGZHUANG);
                            }
                            // this.qznnProxy.gameStandby(data);
                            break;
                        }
                        case 107: {  //游戏叫庄状态
                            this.qznnProxy.playerAddTimes(data);
                            break;
                        }
                        case 108: {  //游戏下注状态
                            this.qznnProxy.gameXiaZhu(data);
                            break;
                        }
                        case 109: {  //游戏摊牌状态
                            this.qznnProxy.gameTanpai(data);
                            break;
                        }
                        case 110: {  //游戏拼牌状态
                            this.qznnProxy.gamePinpai(data);
                            break;
                        }
                        case 111:
                            this.qznnProxy.Xianjiaxiazhu(data);
                            break;
                        // case 112: {//所有玩家亮牌结果
                        //     this.qznnProxy.ShowHandCard();
                        //     break;
                        // }
                        case 113://玩家准备
                            this.qznnProxy.playerPrepare(data);
                            break;
                        case 114: {  //输液记录返回

                            break;
                        }
                        case 120: {  //庄家申请列表

                            break;
                        }
                        case 121: {  //庄家信息

                            break;
                        }
                        case 123: {  //押注已满，提前结束

                            break;
                        }
                        case 504: {  //用户游戏积分返回

                            break;
                        }
                    }
                    break;
                }
                // case 1000: {
                //     if (subCmd == 1) {
                //          EffectUtils.textFadeAway(data["szString"]);
                //     }
                //     break;
                // }
            }
        }
    }
}

